﻿using System.Collections.Generic;
using System.Web.Http;
using Smatime.Web.DAO;
using Smatime.Web.Models;

namespace Smatime.Web.Controllers
{
    public class UserHistoryController : ApiController
    {
        // GET api/userhistory
        public IEnumerable<string> Get()
        {
            return new[] {"value1", "value2"};
        }

        // GET api/userhistory/5
        public UserHistory Get(int id)
        {
            return new UserHistoryRepository().GetById(id);
        }

        [Route("api/userhistory/userAccessId/{id}")]
        public UserHistory GetHistoryId(int id)
        {
            return new UserHistoryRepository().GetByUserAccessId(id);
        }

        // GET new historyId insert by userAccessId
        [Route("api/userhistory/userAccessId/historyid/{id}")]
        public HistoryId GetHistoryIdByUserAccessId(int id)
        {
            return new HistoryIDRepository().GetHistoryId(id);
        }

        // POST api/userhistory
        public void Post([FromBody] UserHistory value)
        {
            var repos = new UserHistoryRepository();
            repos.Insert(value);
        }

        // PUT api/userhistory/5
        public void Put(int id, [FromBody] UserHistory value)
        {
            var repos = new UserHistoryRepository();
            value.Id = id;
            repos.Update(value);
        }

        // DELETE api/userhistory/5
        public void Delete(int id)
        {
        }
    }
}